package com.brainardphotography.blog.web.admin;

import java.io.Serializable;

import com.brainardphotography.blog.BlogUser;
import com.brainardphotography.blog.service.AuthService;
import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;
import com.google.inject.Inject;

public class AdminBrick implements Serializable {
	private static final long serialVersionUID = 7456659335016696203L;

	private UserService users;
	
	private User user = null;
	
	@Inject
	private AuthService authService;

	public AdminBrick() {
		this.users = UserServiceFactory.getUserService();
		this.user = users.getCurrentUser();
	}

	public UserService getUsersService() {
		return this.users;
	}
	
	public User getUser() {
		return this.user;
	}

	public BlogUser getBlogUser() {
		return authService.getBlogUser();
	}
	
	public boolean getAdminUser() {
		if(!users.isUserLoggedIn())
			return false;

		return users.isUserAdmin() ||
				"dorkymusician@gmail.com".equals(user.getEmail().toLowerCase());
	}
}
